<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册</title>
</head>
<body>
    <p>邮箱：  <input id="email" name="email" type="text" placeholder="请输入邮箱..."></p>
    <p>密码：  <input id="password" name="password" type="password"></p>
    <p>验证码：<input id="code" name="code" type="text"> <input id="getCode" type="button" value="获取验证码"></p>
    <input id="register" type="button" value="注册">

<script src="js/jquery-3.4.1.min.js"></script>
<script>
    $("#getCode").click(function(){
        var email = $("#email").val();
        $.ajax({
            url : "http://127.0.0.1:9600/code/create/" + email,
            data : null,
            type : 'get',
            dataType: 'json',
            contentType : "application/x-www-form-urlencoded",
            success: function (resp) {}
        })
    });

    $("#register").click(function(){
        var email = $("#email").val();
        var password = $("#password").val();
        var code = $("#code").val();
        $.ajax({
            url : "http://127.0.0.1:9600/user/register/" + email + "/" + password + "/" + code,
            data : null,
            type : 'get',
            dataType: 'json',
            contentType : "application/x-www-form-urlencoded",
            success: function (resp) {
                if(resp.code === 200){
                    /*跳转至欢迎页*/
                    location.href="welcome.html?email=" + email;
                } else {
                    alert(resp.msg);
                }
            }
        })
    });
</script>
</body>
</html>